
function curring(func) {
    const args = [];
    return function result(...rest) {
        if(rest.length === 0) { // 不传参就执行
            func(...args)
        }
        args.push(...rest);
        return result;
    }
}

const add  = (...args) => args.reduce((a,b) => a + b,0)

const sum = curring(add);

console.log(sum(1,2));